/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.connor.bank.Resource;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 *
 * @author raytang
 */
public class Session {
    
    private static Map<String, Object> session = new LinkedHashMap<>();
    
    public static void addAttribute(String key, Object value){
        if(session.containsKey(key))
            session.remove(key);
        session.put(key, value);
    }
    
    public static Object getAttributeValue(String key){
        return session.get(key);
    }
    
    public static void removeAttribute(String key){
        session.remove(key);
    }
    
    @Override
    public String toString(){
        StringBuilder sb = new StringBuilder();
        for(Map.Entry<String, Object> map : session.entrySet()){
            sb.append("Key: ");
            sb.append(map.getKey());
            sb.append("\tValue: ");
            sb.append(map.getValue());
            sb.append("\n");
        }
        return sb.toString();
    }
    
}
